package tolgahan.albayrak.as3.reflection
{
	public class ParameterInfo extends TypedMemberInfo
	{
		private var _optional:Boolean;
		private var _methodInfo:MethodInfo;
		
		public function ParameterInfo(xml:XML, methodInfo:MethodInfo, memberIndex:uint)
		{
			super(xml, null, memberIndex);
			_methodInfo = methodInfo;
			_optional = String(xml.@optional[0]) == "true";
		}
		
		public function get optional():Boolean
		{
			return _optional;
		}
		
		public function get method():MethodInfo
		{
			return _methodInfo;
		}
		
		override public function get memberOf() : Type
		{
			return _methodInfo.memberOf;
		}
		
		public function validate(value:*):Boolean
		{
			return value == null || value is _type.classReference;
		}
		
		public function toString() : String
		{
			return "arg" + _memberIndex + ":" + _type;
		}
	}
}